﻿using System;
using System.Collections.Generic;
using System.Management;
using System.Text;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementClass mc = new ManagementClass("Win32_DiskDrive");
            ManagementObjectCollection moc = mc.GetInstances();

            foreach (ManagementObject mo in moc)
            {
                Console.WriteLine(">>硬盘详细信息----------------------------------------------------------");
                string name = Convert.ToString(mo.Properties["Name"].Value);
                Console.WriteLine("Name:  " + name);  //name stata 256
                Console.WriteLine("Model:  " + Convert.ToString(mo.Properties["Model"].Value));  //name stata 256
                Console.WriteLine("Description:  " + Convert.ToString(mo.Properties["Description"].Value));  //diskdriver
                Console.WriteLine("InterfaceType:  " + Convert.ToString(mo.Properties["InterfaceType"].Value));  //scsi
                Console.WriteLine("MediaType:  " + Convert.ToString(mo.Properties["MediaType"].Value));    //fixed hard disk
                string strSize = Convert.ToString(mo.Properties["Size"].Value);

                Console.WriteLine("size:" + Convert.ToString(mo.Properties["Size"].Value) + "KB");
                var aaa = Convert.ToString(mo.Properties["Size"].Value);
                UInt64 bbb = UInt64.Parse(aaa);

                var totalsise = (float)Math.Round(bbb / 1000 / 1000 / 1000.0, 0);
                var totalsise2 = (float)Math.Round(bbb / 1024 / 1024 / 1024.0, 0);
                Console.WriteLine("size(除1000):  " + totalsise.ToString() + "GB");
                Console.WriteLine("size(除1024):  " + totalsise2.ToString() + "GB");


                Console.WriteLine("硬盘类型:  " + (CheckSSD.CheckSSDForPhysicalDrive(name) ? "固态" : "机械"));


                Console.WriteLine("");
                Console.WriteLine("");

            }

            Console.ReadLine();
        }
    }
}
